package ByteArray
{
	import flash.display.Sprite;
	import flash.utils.ByteArray;
	
	public class TestBitOperate extends Sprite
	{
		private var buffer:int = 0;
		private var inc:int = 0;
		private var incRead:int = 0;
		
		private var byteArray:ByteArray = new ByteArray();
		
		public function TestBitOperate()
		{
			super();
//			test();
			trace();
		}
		
		public function test():void {
			trace(writeBit(1).toString(2));
			trace(writeBit(1).toString(2));
			trace(writeBit(1).toString(2));
			trace(writeBit(1).toString(2));
			trace(writeBit(0).toString(2));
			trace(writeBit(1).toString(2));
		}
		
		public function writeBit(pBit:uint):uint {
			return buffer |= (pBit << inc++);
		}
		
		public function readBit():uint {
			return uint((buffer & (1 << incRead++ )) != 0);
		}
		
		public function testN(i:int):Boolean {
			return i&1;
		}
	}
}